package sample.stream.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import sample.stream.service.IMessageProvider;

import javax.annotation.Resource;

@RestController
public class SendMessageController {
    @Autowired
    @Qualifier("messageProviderImpl")
    IMessageProvider messageProvider;

    //@Resource跟@Autowired+@Qualifier同理
    @Resource(name="mySourceMessageProviderImpl")
    IMessageProvider mySourceMessageProvider;

    @Resource(name="kafkaSourceMessageProviderImpl")
    IMessageProvider kafkaSourceMessageProvider;

    @GetMapping("/send")
    public String send(){
       return messageProvider.send();
    }

    @GetMapping("/sendToMySource")
    public String sendToMySource(){
        return mySourceMessageProvider.send();
    }

    @GetMapping("/sendToKafkaSource")
    public String sendToKafkaSource(){
        return kafkaSourceMessageProvider.send();
    }
}
